package com.atguigu.g_priority;

public class Demo {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 100; i++) {
                    System.out.println(Thread.currentThread().getName() + " 执行了 ! " + i);
                }
            }
        },"汽车");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 100; i++) {
                    System.out.println(Thread.currentThread().getName() + " 执行了 ! " + i);
                }
            }
        },"火车");

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 100; i++) {
                    System.out.println(Thread.currentThread().getName() + " 执行了 ! " + i);
                }
            }
        },"飞机");

        //设置线程优先级
        t1.setPriority(1);
        t2.setPriority(5);
        t3.setPriority(10);

        System.out.println("t1.getPriority() = " + t1.getPriority());
        System.out.println("t2.getPriority() = " + t2.getPriority());
        System.out.println("t3.getPriority() = " + t3.getPriority());

        //启动线程
        t1.start();
        t2.start();
        t3.start();
    }
}
